//C10:StaticMemberFunctions.cpp
class X
{
    int i;
    static int j;
    public:
        X(int ii = 0): i(ii)
        {
            // Non-static member fucntion can access 
            // static member function or data:
            j = i;
        }
        int val() const { return i; }
        static int incr()
        {
            //! i++;    // Error: static member function-++6-
            // cannot access non-static member data
            return ++j;
        }

        static int f()
        {   
            //! val();   // Error: static member function
            // cannot access non-static member function
            return incr();   // OK -- calls static
        }
};

int X::j = 0;
int main()
{
    X x;
    X* xp = &x;
    x.f();
    xp->f();
    X::f();    // Only works with static members
}